package com.heima.utils.thread;

import com.heima.model.user.pojos.ApUser;

/**
 * @author ybw
 * @version 1.0
 * @date 2021/12/21 21:49
 */
public class ApThreadLocalUtil {
  private static final ThreadLocal<ApUser> AP_USER_THREAD_LOCAL = new ThreadLocal<>();

  /**
   * 添加用户
   *
   * @param apUser
   */
  public static void setUser(ApUser apUser) {
    AP_USER_THREAD_LOCAL.set(apUser);
  }

  /** 获取用户 */
  public static ApUser getUser() {
    return AP_USER_THREAD_LOCAL.get();
  }

  /** 清理用户 */
  public static void clear() {
    AP_USER_THREAD_LOCAL.remove();
  }
}
